        

        var shallCeiStore = new Ext.data.JsonStore({
			url: '/weihe/getList_shallCei',
			root: 'datas',
			fields : [{
						name:'ShallCeiId',mapping:'id'
					},{
						name:'ShallCeiType',mapping:'type'
					},{
						name:'ShallCeiName',mapping:'name'
					},{
						name:'ShallCeiContent',mapping:'content'
					},{
						name:'ShallCeiMoney',mapping:'money'
					},{
				    	name:'ShallCeiRepay',mapping:'repay'
				    },{
				    	name:'ShallCeiBalance',mapping:'balance'
				    },{
     				   name:'ShallCeiDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	},{
     				   name:'ShallCeiRepayDate', mapping:'repayDate',type : 'date', dateFormat:"Y-m-d"
      			  	},{
     				   name:'ShallCeiEndDate', mapping:'endDate',type : 'date', dateFormat:"Y-m-d"
      			  	}],
				    baseParams : {'shallCei.type': 'local'},
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_shallCei',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	
    	

shallCeis = function(){
	
  return{
     
	  shallCeiGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 15,
			store : shallCeiStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var shallCeiGrid = new Ext.grid.GridPanel({
		   id:'shallCeiGrid',
		   title : '货币资金',
		   region : 'center',
		   minColumnWidth : 50,
		   tbar:["-",{
	   						text:"输入查询条件",
								handler:function(){
										shallCeis.infoWin().show();
								}
	   					},"-",{
	   						text:"查看全部",
								handler:function(){
									Ext.getCmp("shallCeiGrid").getStore().baseParams = {'flag': false,'shallCei.type': 'local'};
									Ext.getCmp("shallCeiGrid").getStore().load({params : {start : 0, limit : 15}});
								}
	   			},"-"],
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : shallCeiStore,
		   columns: [
		             {header : '个人借款', dataIndex : 'ShallCeiName',renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
							if(rowIndex == 0){
							return value;
							}else{
							    if(value != store.getAt(rowIndex-1).get('ShallCeiName')){
									return value;
								}else{
									return "";
								}
							}
		             }},
		             {header : '支付用途', dataIndex : 'ShallCeiContent'},
		             {header : '借款日', dataIndex : 'ShallCeiDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '发生额', dataIndex : 'ShallCeiMoney'},
		             {header : '计划还款', dataIndex : 'ShallCeiRepayDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '还款', dataIndex : 'ShallCeiRepay'},
		             {header : '余额', dataIndex : 'ShallCeiBalance'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   		var record = grid.getStore().getAt(rowIndex);
			   		if(record.get('ShallCeiContent')==""){
			   			Ext.Msg.alert('提示','不能编辑统计数据');
			   		}else{
					   Ext.getCmp("shallCeiForm").form.loadRecord(record);
					   Ext.getCmp("shallCeiForm").buttons[0].setText('修改');
			   		}
			   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return shallCeiGrid;
	},
	
	infoWin : function(){
	  	  var infoWin = new Ext.Window({
	  	  	id: 'shallCeiInfo',
	        title:'待收款项查询',
	        layout: 'fit',
	        width:330,    
	        height:250,
	        modal: true,
	        draggable : false,
	        resizable: false,
	        closeAction:"close",
	        plain:true,    
	        items:[shallCeis.queryForm()] 
	        
	    });  
	  		return infoWin;
	  	},
	  	
	  	queryForm : function(){
	  		
	  	 var queryForm = new Ext.form.FormPanel({
				baseCls:"x-plain",
				frame : true,
				autoHeight : true,
				labelAlign : 'right',
				labelWidth : 85,
				defaultType : 'textfield',
					defaults : {
					width : 200
				},
				items : [{
						  fieldLabel: "姓名",
	      	    		  name: "shallCei.name"
				 	  },{
	            		  xtype: 'datefield',
	                      fieldLabel: "借款日期(始)",
	                      format : 'Y-m-d',
	            		  name: "shallCei.date"
					   },{
	            		  xtype: 'datefield',
	                      fieldLabel: "借款日期(终)",
	                      format : 'Y-m-d',
	            		  name: 'shallCei.endDate'
					   },{
	            		  xtype: 'datefield',
	                      fieldLabel: "计划还款日",
	                      format : 'Y-m-d',
	            		  name: 'shallCei.repayDate'
					   }],
				buttons:[{
	        		 text:'确认',
	             	 handler:function(){
	             	 	var name = queryForm.form.findField('shallCei.name').getValue()
	             	 	var date = queryForm.form.findField('shallCei.date').getValue();
	             	 	var endDate = queryForm.form.findField('shallCei.endDate').getValue();
	             	 	var repayDate = queryForm.form.findField('shallCei.repayDate').getValue();
					 Ext.getCmp("shallCeiGrid").getStore().baseParams = {'flag': true,'shallCei.name':name,
						 													  'shallCei.repayDate':repayDate,
						 													  'shallCei.date':date,
						 													  'shallCei.endDate':endDate,
						 													  'shallCei.type': 'local' };
					 Ext.getCmp("shallCeiGrid").getStore().load({params : {start : 0, limit : 15}});
					 queryForm.form.reset();
	                 Ext.getCmp("shallCeiInfo").close();
	              	
	              	}
	              },{
	                 text:'取消',
	                 handler:function(){
	                 	queryForm.form.reset();
	                 	Ext.getCmp("shallCeiInfo").close();
	                 }
	              }]   
	        });
	        return queryForm;
	  	
	  	},
	
	
	
	shallCeiForm : function(){
		var button_add = new Ext.Button({
			text : '添加',
			handler : function() {
					progressConsole();
				if(shallCeiForm.form.isValid()){ 	
					if (shallCeiForm.form.findField("shallCei.id").getValue() == "") {
						shallCeiForm.form.submit({
						  url : '/weihe/add_shallCei',
						   success : function(form, action) {
							  if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
							  }else{
								Ext.Msg.alert('消息', action.result.msg, function() {
									   shallCeiForm.form.reset();
									   Ext.getCmp("shallCeiGrid").getStore().reload();
								});
							  }
						    }
					    });
					}else {
						shallCeiForm.form.submit({
							  url : '/weihe/update_shallCei',
							   success : function(form, action) {
								 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
							    }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										shallCeiForm.form.reset();
										Ext.getCmp("shallCeiGrid").getStore().reload();
										shallCeiForm.buttons[0].setText('添加');
										
									});
								  }
							    }
						    });
					}
			}else{
				Ext.Msg.alert('提示','请输入相关内容');
			}
				}
		
			
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			shallCeiForm.form.reset();
			shallCeiForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		handler : function() {
			var id = shallCeiForm.form.findField('shallCei.id').getValue();
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				Ext.Ajax.request({
					url : '/weihe/delete_shallCei',
					success : function(response) {
						var json = Ext.decode(response.responseText);
						if (json.success) {
								if (json.deny) {
									Ext.Msg.alert('消息', json.msg);
									shallCeiForm.form.reset();
									shallCeiForm.buttons[0].setText('添加');
							}else{
							Ext.Msg.alert('消息', json.msg, function() {
								Ext.getCmp("shallCeiGrid").getStore().load({params : {start : 0, limit : 15}});
								shallCeiForm.form.reset();
								shallCeiForm.buttons[0].setText('添加');
							});
						}
					  }else{
							Ext.Msg.alert('消息', json.msg);
						}
					},
					failure : function() {
						Ext.Msg.alert('错误', '删除失败!');
					},
					params : 'shallCei.id=' + id
				});
			}
		}
	});

	var  shallCeiForm = new Ext.form.FormPanel({
		id : 'shallCeiForm',
		title : '待收款项信息',
		frame : true,
		width : 330,
		region : 'east',
		autoScroll : true,
		collapseMode :'mini',
		collapsible : true,
		labelAlign : 'right',
		labelWidth : 90,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  
			id:'ShallCeiId',
			xtype : 'hidden',  
			name : 'shallCei.id'
		},{  
			id:'ShallCeiType',
			xtype : 'hidden',
			name : 'shallCei.type',
			value: 'local'
		},{
			id:'ShallCeiName',
			fieldLabel : '姓名',
			name : 'shallCei.name'
		},{
			id:'ShallCeiContent',
			fieldLabel : '支付用途',
			name : 'shallCei.content'
		},{
			id: 'ShallCeiDate',
            xtype: 'datefield',
            fieldLabel: "借款日",
            format : 'Y-m-d',
			allowBlank:false,
            name: "shallCei.date"
		},{
			id:'ShallCeiMoney',
			fieldLabel : '发生额',
			name : 'shallCei.money',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id: 'ShallCeiRepayDate',
            xtype: 'datefield',
            fieldLabel: "计划还款日",
            format : 'Y-m-d',
            name: "shallCei.repayDate"
		},{
			id:'ShallCeiRepay',
			fieldLabel : '还款',
			name : 'shallCei.repay',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		}],
		buttons : [button_add,button_clear,button_del]
	});
		return  shallCeiForm;
	}
  }
}();








